
NULL = 

BINARIES = fc_java fc_objc rt_java rt_objc

COMMON_SOURCES = \
  j.ml \
  listAux.ml \
  const.ml \
  ast.ml \
  astO.ml \
  lexer.ml \
  parser.ml \
  compiler.ml \
  $(NULL)

FC_JAVA_SOURCES = \
  $(COMMON_SOURCES) \
  type.ml\
  genSupportClasses.ml\
  backend_Java.ml\
  main_Java.ml\
  $(NULL)

FC_OBJC_SOURCES = \
  $(COMMON_SOURCES) \
  backend_ObjC.ml \
  main_ObjC.ml \
  $(NULL)

GEN_JAVA_SOURCES = \
  $(COMMON_SOURCES) \
  genSupportClasses.ml\
  type.ml\
  backend_Java.ml \
  runtime_Java.ml \
  $(NULL)

GEN_OBJC_SOURCES = \
  $(COMMON_SOURCES) \
  genSupportClasses.ml \
  backend_ObjC.ml \
  runtime_ObjC.ml \
  $(NULL)

FC_OBJS = $(FC_SOURCES:%.ml=%.cmo)
GENOBJC_OBJS = $(GENOBJC_SOURCES:%.ml=%.cmo)

all: $(BINARIES)

fc_java: $(FC_JAVA_SOURCES:%.ml=%.cmo)
	ocamlc -o $@ unix.cma $^

fc_objc: $(FC_OBJC_SOURCES:%.ml=%.cmo)
	ocamlc -o $@ unix.cma $^

rt_java: $(GEN_JAVA_SOURCES:%.ml=%.cmo)
	ocamlc -o $@ unix.cma $^

rt_objc: $(GEN_OBJC_SOURCES:%.ml=%.cmo)
	ocamlc -o $@ unix.cma $^

opt: $(NAME).opt

lexer.cmo : parser.cmi
parser.cmo parser.cmx : parser.cmi

%.cmi : %.mli
	ocamlc -c $<

%.cmo %.cmi : %.ml
	ocamlc -c $<

%.cmx %.cmi : %.ml
	ocamlopt -c $<

%.ml : %.mll
	ocamllex $<

%.ml %.mli : %.mly
	ocamlyacc -v $<

clean:
	rm -f parser.mli parser.output *.cmo *.cmi *.cmx $(BINARIES)

dep:
	ocamldep *.ml *.mli >.depend

include .depend

